from common.connect_db import MyDB

my_db = MyDB()


class DataBasePushMsg:

    @staticmethod
    def get_code(mobile):
        sql = "select code from common_pushmsg_sms_code_logs " \
              "where mobile = '%s' order by created_at desc limit 1" % mobile
        result = my_db.execute_select('pushmsg', sql)
        if len(result) == 1:
            return result[0].code
        else:
            raise ValueError('为查询到记录')
